<template>
<div>
    <tmallHead :bgc="bgc"></tmallHead>
    <tmallBanner></tmallBanner>
    <div class="news" >
        <div class="news1">
            <img src="https://gw.alicdn.com/imgextra/i4/O1CN01eSz6qT1CBHQdQ4coR_!!6000000000042-2-tps-702-56.png_790x10000.jpg_.webp"
                alt="">
        </div>
        <div class="news4" v-if="boolen"></div>
        <div class="news2" :class="news3">
            <span :class="{ 'newsCss': nums == index }" v-for="(v,index) in newsArr" :key="index" @click="toNew(v.pushs,index)">{{v.content}}</span>
        </div>
        <keep-alive>
            <router-view></router-view>
        </keep-alive>
    </div>
    <tmallFooter></tmallFooter>
</div>
</template>

<script>
import TmallBanner from '../Tmall/tmallBanner.vue'
import tmallHead from "../Tmall/tmallHead.vue"
import tmallFooter from "../Tmall/tmallFooter.vue"
export default {
    data(){
        return{
            newsArr:[
                { content: "NEW上新", pushs: "newsPage1",},
                { content: "新礼遇", pushs: "newsPage2",  },
                { content: "新风格", pushs: "newsPage3",  },
                { content: "新面料", pushs: "newsPage4",  },
                { content: "新口味", pushs: "newsPage5", },
            ],
            nums:0,
            bgc:"",
            news3:"",
            boolen:false
        }
    },
    components:{
        tmallHead,
        TmallBanner,
        tmallFooter
    },
    methods: {
        toNew(pushs,index) {
            this.$router.push(`/TmallPage/${pushs}`).catch(err => { })
            this.nums=index
        }
    },
    mounted(){
        window.onscroll = () => {
            if (document.documentElement.scrollTop > 50) {
                this.bgc = "navs"
                
            } else {
                this.bgc = "nav"
            }
            if (document.documentElement.scrollTop > 450) {
                this.news3 = "news3"
                this.boolen=true
            } else {
                this.news3 = "news2"
                this.boolen = false
            }
        }

       
    }
}
</script>

<style scoped>
.news {
    width: 100%;
    height: 100px;
    background-color: #f5f5f5;
    border-radius: 20px;
    /* z-index: 1000; */
    position: relative;
    top: -20px;
}


.news1 {
    width: 94%;
    height: 28.01px;
    padding: 12px 3%;
    overflow: hidden;
}

.news1 img {
    width: 100%;
    height: 100%;
}

.news2 {
    width: 94%;
    height: 38.3px;
    padding: 0 3%;
    background: #f5f5f5;
    display: flex;
    justify-content: space-around;
    font-size: 14px;
    color: #797979;
    z-index: 100;
}
.news3{
    position: fixed;
    top:44px;
    left: 0;
}
.news4{
    width: 94%;
    height: 38.3px;
    padding: 0 3%;
}
.news2 span {
    width: 20%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.newsCss{
    font-size: 16px;
    color: #BDAA86;
}
</style>